package com.qfmy.controller.novel;

import com.qfmy.service.novel.RatingService;
import common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 清风明月
 * @Package com.qfmy.controller.novel
 * @date 2025/6/7
 * @description 评分
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/app/rating")
public class RatingController {

    /**
     * 注入service
     */
    @Autowired
    private RatingService ratingService;

    /**
     * 获取当前用户评分
     */
    @RequestMapping("/getRating")
    public Result<Double> getRating(@RequestParam Long novelId) {
        Double rating = ratingService.getRating(novelId);
        return Result.ok(rating);
    }

    /**
     * 进行评分
     */
    @RequestMapping("/setRating")
    public Result setRating(@RequestParam Long novelId, @RequestParam Double score) {
        ratingService.setRating(novelId, score);
        return Result.ok();
    }

}
